package com.octopus.optiworks.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.octopus.optiworks.model.EmployeeRole;

@Component
public class RoleDao extends GenericHibernateDao<EmployeeRole, Long>{
	
	public List<EmployeeRole> loadAll(){
		List<EmployeeRole> list = super.find("from EmployeeRole r order by r.name", new String[]{});
		return list;
	}
	
	public void delete(Long roleId) {
		String str = "delete from user_role where roleid= :roleid";
		Map<String, Object> parms = new HashMap<String, Object>();
		parms.put("roleid", roleId);
		super.executeSQL(str, parms);
		super.deleteByKey(roleId);
	}

}
